//
//  SHHomeGuideModel.swift
//  shaohuo
//
//  Created by vicoo on 16/8/18.
//  Copyright © 2016年 lchenc3. All rights reserved.
//

import UIKit

class SHHomeGuideModel: NSObject {
    
    init(navController: UIViewController?) {
        super.init()
        self.navigationController = navController
    }
    
    var navigationController: UIViewController?
    
    /**
     显示接单提示层
     */
    func showPickOrderGuideView() {
        /*
        let leftNavibarItem = EAFeatureItem(focusRect: CGRect(x: 0, y: 25, width: 50, height: 35), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        leftNavibarItem.introduce = "点击后进入个人中心"
        leftNavibarItem.introduceFont = UIFont.systemFontOfSize(12)
        leftNavibarItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        //leftNavibarItem.introduceAligmentDirection = EAFeatureItemAlignmentDirection.Bottom
       
        let rightNavBarItem = EAFeatureItem(focusRect: CGRect(x: CGRectGetWidth(UIScreen.mainScreen().bounds) - 50, y: 25, width: 50, height: 35), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        rightNavBarItem.introduce = "消息通知列表都在这里"
        rightNavBarItem.introduceFont = UIFont.systemFontOfSize(12)
        rightNavBarItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        rightNavBarItem.introduceAligmentDirection = EAFeatureItemAlignmentDirection.Left
        
        let pickOrderItem = EAFeatureItem(focusRect: CGRect(x: CGRectGetWidth(UIScreen.mainScreen().bounds) - 50, y: 104, width: 50, height: 35), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        pickOrderItem.introduce = "点击后停止接单"
        pickOrderItem.introduceFont = UIFont.systemFontOfSize(12)
        //pickOrderItem.introduceAligmentDirection = EAFeatureItemAlignmentDirection.Bottom
        pickOrderItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        
        self.navigationController?.view.showWithFeatureItems([leftNavibarItem, rightNavBarItem , pickOrderItem], saveKeyName: "showPickOrderGuideView", inVersion: nil)
        */
        
    }
    /**
     显示普通用指引
     */
    func showHomeGuideView() {
        /*
        let leftNavibarItem = EAFeatureItem(focusRect: CGRect(x: 0, y: 25, width: 50, height: 35), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        leftNavibarItem.introduce = "点击后进入个人中心"
        leftNavibarItem.introduceFont = UIFont.systemFontOfSize(12)
        leftNavibarItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        //leftNavibarItem.introduceAligmentDirection = EAFeatureItemAlignmentDirection.Bottom
        
        let rightNavBarItem = EAFeatureItem(focusRect: CGRect(x: CGRectGetWidth(UIScreen.mainScreen().bounds) - 50, y: 25, width: 50, height: 35), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        rightNavBarItem.introduce = "消息通知列表都在这里"
        rightNavBarItem.introduceFont = UIFont.systemFontOfSize(12)
        rightNavBarItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        //rightNavBarItem.introduceAligmentDirection = EAFeatureItemAlignmentDirection.Left
        self.navigationController?.view.showWithFeatureItems([leftNavibarItem, rightNavBarItem ], saveKeyName: "showHomeGuideView", inVersion: "2.0")
        */
        
        if UserDefaults.standard.bool(forKey: "showHelpSendGuid") == false {
           
            let imageView = UIImageView(image: UIImage(named: "icon_help_send_guid"))
            imageView.frame = CGRect(x: 0, y: 0, width: 299, height: 309)
            
            self.navigationController?.lew_presentPopupView(imageView, animation: LewPopupViewAnimationSpring(), dismissed: {
                 UserDefaults.standard.set(true, forKey: "showHelpSendGuid")
            })
        }
        
    }
    /**
     显示左侧菜单提示
     */
    func showDrawerGuideView() {
        
        let focusRect = CGRect(x: 0, y: UIScreen.main.bounds.height - 85, width: 120, height: 59)
        let applyShipperItem = EAFeatureItem(focus: focusRect, focusCornerRadius: 0, focus: UIEdgeInsets.zero)
        applyShipperItem?.introduce = "做一名光荣的捎货人吧"
        applyShipperItem?.introduceFont = UIFont.systemFont(ofSize: 12)
        applyShipperItem?.introduceBackgroundColor = UIColor(hexString: "63AA6B").withAlphaComponent(0.8)
        applyShipperItem?.introduceAlignmentPriority = EAFeatureItemAlignmentPriority.topFirst
        self.navigationController?.view.show(with: [applyShipperItem!], saveKeyName: "showDrawerGuideView", inVersion: nil)
 
    }
    /**
     显示帮我买提示
     */
    func showHelpMeBuyGuideView() {
        /*
        let leftNavibarItem = EAFeatureItem(focusRect: CGRect(x: 0, y: CGRectGetHeight(UIScreen.mainScreen().bounds) - 44, width: 55, height: 44), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        leftNavibarItem.introduce = "也可以手动填写购物信息哦"
        leftNavibarItem.introduceFont = UIFont.systemFontOfSize(12)
        leftNavibarItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        leftNavibarItem.introduceAlignmentPriority = EAFeatureItemAlignmentPriority.TopFirst
        
        
        let rightNavBarItem = EAFeatureItem(focusRect: CGRect(x: 55, y: CGRectGetHeight(UIScreen.mainScreen().bounds) - 44, width: CGRectGetWidth(UIScreen.mainScreen().bounds) - 55, height: 44), focusCornerRadius: 0, focusInsets: UIEdgeInsetsZero)
        rightNavBarItem.introduce = "长按语音录入商品名称"
        rightNavBarItem.introduceFont = UIFont.systemFontOfSize(12)
        rightNavBarItem.introduceBackgroundColor = UIColor(hexString: "63AA6B").colorWithAlphaComponent(0.8)
        rightNavBarItem.introduceAlignmentPriority = EAFeatureItemAlignmentPriority.TopFirst
        self.navigationController?.view.showWithFeatureItems([leftNavibarItem, rightNavBarItem ], saveKeyName: "showHelpMeBuyGuideView", inVersion: "2.0")
         */
        
        
        if UserDefaults.standard.bool(forKey: "showHelpMeBuyGuide") == false {
            
            let imageView = UIImageView(image: UIImage(named: "icon_help_buy_guid"))
            imageView.frame = CGRect(x: 0, y: 0, width: 281, height: 309)
            
            self.navigationController?.lew_presentPopupView(imageView, animation: LewPopupViewAnimationSpring(), dismissed: {
                UserDefaults.standard.set(true, forKey: "showHelpMeBuyGuide")
            })
        }
        
    }
    
    func showHelpMeGuideView() {
        if UserDefaults.standard.bool(forKey: "showHelpMeGuide") == false {
            
            let imageView = UIImageView(image: UIImage(named: "icon_help_guid"))
            imageView.frame = CGRect(x: 0, y: 0, width: 292, height: 309)
            
            self.navigationController?.lew_presentPopupView(imageView, animation: LewPopupViewAnimationSpring(), dismissed: {
                UserDefaults.standard.set(true, forKey: "showHelpMeGuide")
            })
        }
    }
}

